/************************************************************************

							Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  							   compressed_buffer.h

	$Header: /resource_editor/compressed_buffer.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( COMPRESSED_BUFFER_H_INCLUDED )
#define COMPRESSED_BUFFER_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "compressed_filter.h"
#include "resource_datatypes.h"
#include "sized_int_types.h"
#include "streambuf_ptr.h"

/////////////////////////////////////////////////////////////////////////////
// t_compressed_buffer_base class - auxillary class used as a base class for
// t_deflate_buffer and t_inflate_buffer in order to get the order of
// initialization and deinitialization correct.

class t_compressed_buffer_base
{
public:
	// Constructor
	t_compressed_buffer_base( t_streambuf_ptr buffer ) : m_buffer( buffer ) {}

private:
	// Data members
	t_streambuf_ptr		m_buffer;
};

/////////////////////////////////////////////////////////////////////////////
// t_deflate_buffer class

class t_deflate_buffer : private t_compressed_buffer_base, public t_deflate_filter
{
public:
	//	Constructor
	t_deflate_buffer( t_streambuf_ptr buffer, t_int32 datatype = k_medium_compression_binary );
};

inline t_deflate_buffer::t_deflate_buffer( t_streambuf_ptr buffer, t_int32 datatype )
	:	t_compressed_buffer_base( buffer ),
		t_deflate_filter( *buffer, datatype )
{
}

/////////////////////////////////////////////////////////////////////////////
//	t_inflate_buffer class

class t_inflate_buffer : private t_compressed_buffer_base, public t_inflate_filter
{
public:
	//	Constructor
	t_inflate_buffer( t_streambuf_ptr buffer );
};

inline t_inflate_buffer::t_inflate_buffer( t_streambuf_ptr buffer )
	:	t_compressed_buffer_base( buffer ),
		t_inflate_filter( *buffer )
{
}

#endif // !defined( COMPRESSED_BUFFER_H_INCLUDED )
